package com.mashibing.controller;


import com.mashibing.internalcommon.dto.Car;
import com.mashibing.internalcommon.dto.ResponseResult;
import com.mashibing.internalcommon.response.OrderDriverResponse;
import com.mashibing.service.ICarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 孟瑞达
 * @since 2025-06-18
 */
@RestController
public class CarController {

    @Autowired
    private ICarService carService;

    @PostMapping("/addCar")
    public ResponseResult addCar(@RequestBody Car car){
        return carService.addCar(car);
    }

    /**
     * 根据id查询车辆信息
     * @param carId 车辆id
     * @return
     */
    @GetMapping("/getDriverById/{carId}")
    public ResponseResult<Car> getDriverById(@PathVariable String carId){
        return carService.getDriverById(carId);
    }

    /**
     * 根据id查询司机信息
     * @param carId 车辆id
     * @return
     */
    @GetMapping("/getDriverUserInfoByCarId/{carId}")
    public ResponseResult<OrderDriverResponse> getDriverUserInfoByCarId(@PathVariable String carId){
        return carService.getDriverUserInfoByCarId(carId);
    }
}
